package com.smarthospital.service.impl;

import com.google.common.collect.Lists;
import com.smarthospital.common.util.IDGeneratorUtil;
import com.smarthospital.common.util.SHDateUtil;
import com.smarthospital.dao.daoService.HospitalDaoService;
import com.smarthospital.entity.pojo.Hospital;
import com.smarthospital.entity.pojo.Report;
import com.smarthospital.entity.pojo.User;
import com.smarthospital.service.ReportGeter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import java.util.Date;
import java.util.List;

/**
 * create by sym  2021/6/19 14:26.
 */
@Service
public class LuoHUReportGeterImpl implements ReportGeter {

    private Hospital hospital;

    @Autowired
    private HospitalDaoService hospitalDaoService;

    @Value("${sh.deploy.host}")
    private String host;

    @Override
    public List<Report> getReportFromHospital(User user) {
        Report build = Report.builder().hospital(hospital.getHospitalName())
                .customer(user.getId()+"").reportId(hospital.getHospitalCode()+IDGeneratorUtil.getReportId()).reportName("孕后检测")
                .reportDoctor("康复专家刘医生").reportUrl("http://"+host+"/group1/M00/00/00/rB3r6WDKAaGAcZiCAArzUzAmM_Y984.pdf")
                .creator("sys").updator("sys").createTime(SHDateUtil.getDateStr(new Date(),SHDateUtil.yyyMMddHHmm)).updateTime(SHDateUtil.getDateStr(new Date(),SHDateUtil.yyyMMddHHmm))
                .reportMan("")
                .reportManIdCard(user.getIdCardNum()).build();
        return Lists.newArrayList(build);
    }

    @Override
    @PostConstruct
    public Hospital initHospital() {
        Hospital hospital = hospitalDaoService.selectHospitalByCode("luohu");
        this.hospital = hospital;
        return hospital;
    }
}
